struct ListNode* removeElements(struct ListNode* head, int val)
{
    assert(head);
    ListNode* cur = head;
    if (cur == NULL)
    {
        return NULL;
    }
    if (cur->next == NULL)
    {
        if (cur == val)
        {
            return NULL;
        }
        else
        {
            return val;
        }
    }
    else
    {
        while (cur->next != val)
        {
            cur = cur->next;
        }
        cur->next = val->next;
        free(val);
    }
}